/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Radiostation_POJOS;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Nikos
 */
@Entity
@Table(name = "MUSICGROUP")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Musicgroup.findAll", query = "SELECT m FROM Musicgroup m"),
    @NamedQuery(name = "Musicgroup.findByMusicgroupId", query = "SELECT m FROM Musicgroup m WHERE m.musicgroupId = :musicgroupId"),
    @NamedQuery(name = "Musicgroup.findByName", query = "SELECT m FROM Musicgroup m WHERE m.name = :name"),
    @NamedQuery(name = "Musicgroup.findByFormationdate", query = "SELECT m FROM Musicgroup m WHERE m.formationdate = :formationdate")})
public class Musicgroup implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "MUSICGROUP_ID")
    private Integer musicgroupId;
    @Basic(optional = false)
    @Column(name = "NAME")
    private String name;
    @Basic(optional = false)
    @Column(name = "FORMATIONDATE")
    private String formationdate;
    @ManyToMany(mappedBy = "musicgroupList")
    private List<Artist> artistList;
    @OneToMany(mappedBy = "musicgroup")
    private List<Album> albumList;

    public Musicgroup() {
    }

    public Musicgroup(Integer musicgroupId) {
        this.musicgroupId = musicgroupId;
    }

    public Musicgroup(Integer musicgroupId, String name, String formationdate) {
        this.musicgroupId = musicgroupId;
        this.name = name;
        this.formationdate = formationdate;
    }

    public Integer getMusicgroupId() {
        return musicgroupId;
    }

    public void setMusicgroupId(Integer musicgroupId) {
        this.musicgroupId = musicgroupId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getFormationdate() {
        return formationdate;
    }

    public void setFormationdate(String formationdate) {
        this.formationdate = formationdate;
    }

    @XmlTransient
    public List<Artist> getArtistList() {
        return artistList;
    }

    public void setArtistList(List<Artist> artistList) {
        this.artistList = artistList;
    }

    @XmlTransient
    public List<Album> getAlbumList() {
        return albumList;
    }

    public void setAlbumList(List<Album> albumList) {
        this.albumList = albumList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (musicgroupId != null ? musicgroupId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Musicgroup)) {
            return false;
        }
        Musicgroup other = (Musicgroup) object;
        if ((this.musicgroupId == null && other.musicgroupId != null) || (this.musicgroupId != null && !this.musicgroupId.equals(other.musicgroupId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Radiostation_POJOS.Musicgroup[ musicgroupId=" + musicgroupId + " ]";
    }
    
}
